package ymy;

import org.junit.Test;

import java.lang.reflect.Constructor;

/**
 * @author com.ymy.hadoop
 * @date 2018/12/15 14:46
 */
public class ConstructorApp {

    @Test
    public void test01()throws Exception{
        Class<?> clazz = Class.forName("ymy.Student");
        Constructor<?>[] constructors = clazz.getDeclaredConstructors();

        for (Constructor constructor : constructors){
        //  System.out.println(constructor);
          Class<?>[] parameterTypes = constructor.getParameterTypes();
          System.out.println(constructor.getName());
          for (Class<?>parameterType : parameterTypes){
              System.out.println(".." + parameterType);
          }

        }
    }

    @Test
    public void test02()throws Exception{
        Class<?>clazz = Class.forName("ymy.Student");
        Constructor constructor = clazz.getConstructor(String.class,String.class,Integer.class);

        Object object = constructor.newInstance("xx","女",40);
        System.out.println(object);
    }
}
